<% layout('/layouts/default.html', {title: '数据管理', libs:
['validate','fileupload','ueditor','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(ztBanner.isNewRecord ? '新增轮播图' :
				'编辑轮播图')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool"
					data-widget="collapse">
					<i class="fa fa-minus"></i>
				</button>
			</div>
		</div>
		
		<#form:form id="inputForm" model="${ztBanner}"
		action="${ctx}/ztBanner/save" method="post" class="form-horizontal">
		<div class="box-body">
			<div class="form-unit">${text('轮播图信息')}</div>
			<#form:hidden path="id"/>
			
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('轮播图标题')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8"><#form:input path="title"
							maxlength="200" class="form-control  "/></div>
					</div>
				</div>
				
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('权重')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8"><#form:input path="weig"
							onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');"
							maxlength="20" class="form-control"/></div>
					</div>
				</div>
				
				
				
			</div>
			
			<div class="row">
			<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('类型')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8"><#form:select path="type"  id="bannerSelect"
							dictType="zt_banner_type" blankOption="true" class="form-control required"
							/></div>
					</div>
				</div>
				<div class="col-xs-6" id="selectActi">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('文章链接')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8"><#form:input path="link"
							 class="form-control "/></div>
					</div>
				</div>
				<div class="col-xs-6" id="selectGoods">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('轮播商品')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
						
							 <#form:select path="file"
							items="${ztGoodsList}" itemLabel="title" itemValue="id"
							blankOption="true" class="form-control "/>
							 
							 </div>
					</div>
				</div>
				
				<div class="col-xs-6" id="selectBrand">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('品牌专场')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
						
							 <#form:select path="brandid"
							items="${brandidList}" itemLabel="name" itemValue="id"
							blankOption="true" class="form-control "/>
							 
							 </div>
					</div>
				</div>
				
				
			</div>

			<div class="row">
				<div class="col-xs-12">
					<div class="form-group">
						<label class="control-label col-sm-2">${text('图片上传：<br/>尺寸375*225')}</label>
						<div class="col-sm-10">
					
							<#form:fileupload id="upload2" returnPath="true"
	filePathInputId="img"  bizKey="${ztBanner.id}" bizType="user_upload2"
	uploadType="image" readonly="false" maxUploadNum="1" isMini="false"/>
	<#form:input name="img" class="form-control"/>
							</div>
					</div>
				</div>
			</div>
			

		</div>
		<div class="box-footer">
			<div class="row">
				<div class="col-sm-offset-2 col-sm-10">
					<% if (hasPermi('ztBanner:ztBannerData:edit')){ %>
					<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit">
						<i class="fa fa-check"></i> ${text('保 存')}
					</button>
					&nbsp; <% } %>
					<button type="button" class="btn btn-sm btn-default" id="btnCancel"
						onclick="js.closeCurrentTabPage()">
						<i class="fa fa-reply-all"></i> ${text('关 闭')}
					</button>
				</div>
			</div>
		</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>

$(document).ready(
		function() {
			var bannerSelect=$("#bannerSelect").val();
			
			
			if(bannerSelect==4){//文章
				$("#selectActi").show();
				$("#selectGoods").hide();
				$("#selectBrand").hide();
			}else if(bannerSelect==2){//商品
				$("#selectActi").hide();
				$("#selectGoods").show();
			}else if(bannerSelect==1){//专场
				$("#selectActi").hide();
				$("#selectGoods").hide();
				$("#selectBrand").show();
			}else{
				$("#selectActi").hide();
				$("#selectGoods").hide();
				$("#selectBrand").hide();
			}
			
			
			$("#bannerSelect").change(function() {
				var s = $(this).val();
				
				
				if(s==4){//文章
					$("#selectActi").show();
					$("#selectGoods").hide();
					$("#selectBrand").hide();
				}else if(s==2){//商品
					$("#selectActi").hide();
					$("#selectGoods").show();
				}else if(s==1){//专场
					$("#selectActi").hide();
					$("#selectGoods").hide();
					$("#selectBrand").show();
				}else{
					$("#selectActi").hide();
					$("#selectGoods").hide();
					$("#selectBrand").hide();
				}
			});
		});
	

	$("#inputForm").validate({
		submitHandler : function(form) {
			js.ajaxSubmitForm($(form), function(data) {
				js.showMessage(data.message);
				if (data.result == Global.TRUE) {
					js.closeCurrentTabPage(function(contentWindow) {
						contentWindow.page();
					});
				}
			}, "json");
		}
	});
</script>